package cn.tedu.spring.life;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

/**
 * BeanFactoryPostProcessor
 * BeanFactory bean工厂
 * PostProcessor 后期处理器
 * BeanFactoryPostProcessor bean工厂后期处理器
 * Spring官方不建议自行处理！
 */
@Component
public class MyBFPP implements BeanFactoryPostProcessor {
    /**
     * postProcessBeanFactory 在Spring加载全部Bean定义之后执行
     *
     * @param configurableListableBeanFactory 这个对象封装了全部Bean定义信息
     * @throws BeansException  bean定义加载失败异常
     */
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        //需求，获取全部的Bean名称
        String[] names = configurableListableBeanFactory.getBeanDefinitionNames();

//        for (String name : names) {
//            System.out.println(name);
//        }
    }
}
